<template>
    <view class="pub_page pub_index">
        <image class="bg_img" mode="widthFix" :src="standing == 'user' ? bg_user : bg_manage" />
        <pub-head headerName="index" :headerConfig="headerConfig"></pub-head>
        <div class="page_box page_box_scroll" :style="{ 'height': `calc(100vh - ${headerHeight})` }">
            <indexUser ref="indexUser" v-if="standing == 'user'"></indexUser>
            <indexManage ref="indexManage" v-if="standing == 'manage'"></indexManage>
        </div>
    </view>
</template>

<script>
import indexUser from './components/user.vue'
import indexManage from './components/manage.vue'
export default {
    components: { indexUser, indexManage },
    data() {
        return {
            headerConfig: {
                title: '首页',//标题栏内容
                title_color: '#fff',
                left_content: '',
            },
            headerHeight: getApp().globalData.headerHeight,
            standing: this.$store.state.standing,

            bg_user: '',
            bg_manage: '',

            load: false,
        };
    },
    onLoad() {
        // console.log(getApp().globalData);
    },
    onShow() {
        if (this.$store.state.standing == 'user') {
            const bg_user = uni.getStorageSync('bg_user');
            this.bg_user = bg_user ? bg_user : this.$store.state.bg_normal_user;
            console.log(bg_user, this.bg_user);
            if (this.load) {
                this.$refs.indexUser.initPage();
            } else {
                this.load = true;
            }
        } else if (this.$store.state.standing == 'manage') {
            const bg_manage = uni.getStorageSync('bg_manage');
            this.bg_manage = bg_manage || this.$store.state.bg_normal_manage;
            console.log(bg_manage, this.bg_manage);
            if (this.load) {
                this.$refs.indexManage.initPage();
            } else {
                this.load = true;
            }
        }
    },
    methods: {},
};
</script>

<style lang="scss" scoped>
@import "@/common/css/index.scss";
</style>
